<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
    <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
    <title>合伙人</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .head {
            background: #FDB876;
            height: 350px;
        }

        .head>img {
            width: 100%;
            height: 350px;
        }

        .bottom {
            background: #FDB876;
            width: 90%;
            padding: 5%;
        }

        .content {
            width: 90%;
            padding: 5%;
            margin: 0 auto;
            border-radius: 15px;
            background: #fff;
            box-shadow: 0px 2px 15px 1px #dcdcdc;
        }

        .button {
            display: flex;
            justify-content: space-around;
            align-items: center;
            margin: 15px auto;
        }

        .button_one {
            width: 105px;
            border-radius: 5px;
            background: #FC7D55;
            color: #fff;
            letter-spacing: 1px;
            text-align: center;
            height: 35px;
            line-height: 35px;
            font-size: 14px;
        }

        .button_two {
            border-radius: 5px;
            background: #FEBEAA;
            color: #FC7D55;
            letter-spacing: 1px;
            text-align: center;
            height: 35px;
            width: 105px;
            line-height: 35px;
            font-size: 14px;
        }

        .content_img {
            display: flex;
            flex-direction: column;
        }

        .content_img>img {
            margin: 0 auto 15px auto;
            width: 90%;
        }

        .partner {
            display: block;
            margin: 20px auto;
            outline: 0;
            border: 0;
            border-radius: 999px;
            color: #fff;
            background: #E55056;
            width: 75%;
            height: 38px;
            letter-spacing: 1px;
        }

        .progress {
            display: flex;
            align-items: center;
            flex-direction: column;
        }

        .trangle {
            width: 0;
            height: 0;
            border: 15px solid #000;
            border-top-color: #FC7D55;
            border-bottom-color: transparent;
            border-left-color: transparent;
            border-right-color: transparent;
        }

        .init {
            width: 90%;
            border: 1px solid #FC7D55;
            border-radius: 5px;
            text-align: center;
            height: 50px;
            line-height: 50px;
            letter-spacing: 1px;
            color: #FC7D55;
            margin-bottom: 15px;
            font-size: 12px;
            font-weight: 600;
        }
    </style>
</head>

<body>
    <div class="container">
        <div class="head">
            <img src="./image/head1.png" alt="">
        </div>
        <div class="bottom">
            <div class="content">
                <div class="button">
                    <div class="button_one">赚钱项目</div>
                    <div class="button_two">分销流程</div>
                </div>
                <div class="content_img">
                    <img class="img_1" src="./image/11.png" alt="" />
                    <img class="img_2" src="./image/22.png" alt="" />
                    <img class="img_3" src="./image/33.png" alt="" />
                    <img class="img_4" src="./image/44.png" alt="" />
                </div>
                <div class="progress">
                    <div class="init">参加活动成为分销合伙人</div>
                    <div class="trangle"></div>
                    <div class="init">分享项目海报</div>
                    <div class="trangle"></div>
                    <div class="init">好友通过分享海报进入活动页面</div>
                    <div class="trangle"></div>
                    <div class="init">好友购买商品并完成交易/项目成功</div>
                    <div class="trangle"></div>
                    <div class="init">交易完成/项目成交后7日内可收到分销奖励</div>
                </div>
            </div>
            <button class="partner">成为合伙人</button>
        </div>
    </div>
</body>
<script src="./js/jquery-3.5.1.min.js"></script>
<script>
    window.onpageshow = (() => {
        $('.button_two').css({
            'background': '#FEBEAA',
            'color': '#FC7D55'
        })
        $('.button_one').css({
            'background': '#FC7D55',
            'color': '#fff'
        })
        $('.progress').hide()
        $('.content_img').show()
        let user_id = getUrldata('Uid')
        let key = getUrldata('key')
        let u = navigator.userAgent
        let img_arr = []
        // 判断ios
        let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
        // 判断android
        let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1
        //判断微信
        function isWeiXin() {
            var ua = window.navigator.userAgent.toLowerCase();
            if (ua.match(/MicroMessenger/i) == 'micromessenger') {
                return true; // 是微信端
            } else {
                return false;
            }
        }

        $('.button_two').click(() => {
            $('.button_one').css({
                'background': '#FEBEAA',
                'color': '#FC7D55'
            })
            $('.content_img').hide()
            $('.progress').show()
            $('.button_two').css({
                'background': '#FC7D55',
                'color': '#fff'
            })
        })

        $('.button_one').click(() => {
            $('.button_two').css({
                'background': '#FEBEAA',
                'color': '#FC7D55'
            })
            $('.progress').hide()
            $('.content_img').show()
            $('.button_one').css({
                'background': '#FC7D55',
                'color': '#fff'
            })
        })

        function info_alert(param) {
            if (isWeiXin()) {
                (() => {
                    window.alert = function (name) {
                        var iframe = document.createElement("IFRAME");
                        iframe.style.display = "none";
                        iframe.setAttribute("src", 'data:text/plain');
                        document.documentElement.appendChild(iframe);
                        window.frames[0].window.alert(name);
                        iframe.parentNode.removeChild(iframe);
                    }
                })()
                alert(param)
                return
            }
            if (isiOS) {
                window.webkit.messageHandlers.showAlert.postMessage(param)
                return
            }
            if (isAndroid) {
                window.TiantianCharge_Android.showAlert(param)
                return
            }
        }

        // 先判断是否为合伙人 判断图片是否可以点击
        $.ajax({
            url: 'https://api.cd1a.cn/index.php/activity/Trans/ispartner',
            type: 'POST',
            data: {
                userid_locked: user_id
            },
            dataType: 'json'
        }).then(res => {
            console.log(res)
            // 是合伙人
            if (res.code == '1') {
                // 隐藏合伙人按钮
                $('.partner').hide()
                $.ajax({
                    url: 'https://api.cd1a.cn/index.php/index27/Activity/config_partner',
                    type: 'POST',
                    data: {
                        userid_locked: user_id
                    },
                    dataType: 'json'
                }).then(res => {
                    console.log(res)
                    if (res.result_code == '300') {
                        for (let i = 0; i < res.data.length; i++) {
                            img_arr.push(res.data[i])
                        }
                        // 购车商城
                        $('.img_1').click(() => {
                            if (img_arr[0].is_enter == '2') {
                                if (isWeiXin()) {
                                    if (window.__wxjs_environment === 'miniprogram') {
                                        wx.miniProgram.navigateTo({
                                            url: '/pages/car/car'
                                        })
                                    }
                                }
                                if (isiOS) {
                                    window.webkit.messageHandlers.goShop.postMessage('11111')
                                }
                                if (isAndroid) {
                                    window.TiantianCharge_Android.openMarket()
                                }
                            } else {
                                info_alert(img_arr[0].msg)
                            }
                        })

                        // 免费换电
                        $('.img_2').click(() => {
                            if (img_arr[1].is_enter == '2') {
                                window.location.href = img_arr[1].url + '?Uid=' + user_id
                            } else {
                                info_alert(img_arr[1].msg)
                            }
                        })

                        // 推荐代理
                        $('.img_3').click(() => {
                            if (img_arr[2].is_enter == '2') {
                                window.location.href = img_arr[2].url + '?Uid=' + user_id
                            } else {
                                info_alert(img_arr[2].msg)
                            }
                        })

                        // 安装转介
                        $('.img_4').click(() => {
                            if (img_arr[3].is_enter == '2') {
                                window.location.href = img_arr[3].url + '?Uid=' + user_id
                            } else {
                                info_alert(img_arr[3].msg)
                            }
                        })
                    } else {
                        info_alert(res.msg)
                    }
                })
            } else {
                // 不是是合伙人或者其他
                return
            }
        })

        $('.partner').click(() => {
            window.location.href = 'partner_input.html?Uid=' + user_id + '&key=' + key
        })

        function getUrldata(name) {
            let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            let r = window.location.search.substr(1).match(reg);
            if (r != null) return decodeURI(r[2]);
            return null;
        }
    })
</script>

</html>